package com.xwyzsn.backend.job.controller;


import com.xwyzsn.backend.job.common.Result;
import com.xwyzsn.backend.job.service.impl.ProjectServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author xwyzsn
 * @since 2023-03-03
 */
@RestController
@RequestMapping("/job/project")
@CrossOrigin(origins = "*", maxAge = 3600)
public class ProjectController {
    @Autowired
    private ProjectServiceImpl projectServiceimpl;

    @GetMapping("/getStatistics")
    public Result getStatistics() {
        return projectServiceimpl.getStatistics();
    }

    @GetMapping("/getrecent")
    public Result getRecent(@RequestParam("dept") String dept) {
        return projectServiceimpl.getRecent(dept);
    }

    @GetMapping("/getall")
    public Result getAll(@RequestParam("dept") String dept) {
        return projectServiceimpl.getAll(dept);
    }

    @GetMapping("/check")
    public Result check(@RequestParam("snum") String snum) {
        return projectServiceimpl.check(snum);
    }

    @PostMapping("/confirm")
    private Result check(@RequestParam("snum") String snum, @RequestParam("pid") String pid
                         ) {
        return projectServiceimpl.confirm(snum, pid);
    }
    @PostMapping("/cancel")
    private Result cancel(@RequestParam("snum") String snum, @RequestParam("pid") String pid) {
        return projectServiceimpl.cancel(snum, pid);
    }

    @PostMapping("update")
    private Result update(@RequestParam("pid") String pid,
                          @RequestParam("pname") String pname,
                          @RequestParam("pdesc") String pdesc){
        return projectServiceimpl.update(pid,pname,pdesc);
    }
    @PostMapping("add")
    private Result add(@RequestParam("pname") String pname,
                       @RequestParam("pdesc") String pdesc,
                       @RequestParam("tnum") String tnum,
                       @RequestParam("dept") String dept){
        return projectServiceimpl.add(pname,pdesc,dept,tnum);
    }
    @GetMapping("delete")
    private Result delete(@RequestParam("pid") String pid){
        return projectServiceimpl.delete(pid);
    }

    @GetMapping("getselected")
    private Result getStudentStatus(@RequestParam(value = "dept",required = false) String dept){
        return projectServiceimpl.getStudentStatus(dept);
    }
    @GetMapping("getnotselected")
    private Result getStudentNotStatus(@RequestParam(value = "dept",required = false) String dept){
        return projectServiceimpl.getStudentNotStatus(dept);
    }
    @GetMapping("getselectedproject")
    private Result getSelectedProject(@RequestParam("dept") String dept){
        return projectServiceimpl.getSelectedProject(dept);
    }
    @GetMapping("getnotselectedproject")
    private Result getNotSelectedProject(@RequestParam("dept") String dept){
        return projectServiceimpl.getNotSelectedProject(dept);
    }




}
